package com.yupi.usercenter.controller;

import com.yupi.usercenter.common.BaseResponse;
import com.yupi.usercenter.common.ResultUtils;
import com.yupi.usercenter.service.WebSocketService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * WebSocket相关接口
 */
@RestController
@RequestMapping("/websocket")
public class WebSocketController {

    /**
     * 获取在线用户列表
     */
    @GetMapping("/online-users")
    public BaseResponse<List<Long>> getOnlineUsers() {
        List<Long> onlineUsers = WebSocketService.getOnlineUserIds();
        return ResultUtils.success(onlineUsers);
    }
}
